<?php

class Teacher extends CI_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->spark('ion_auth/2.3.2');
		$this->load->database();
		$this->load->helper('javascript');
	}

	public function index()
	{
	
		//is the user logged in?
		if (!$this->ion_auth->logged_in())
		{
			//redirect them back to the page they came from
			redirect($this->config->item('base_url'), 'refresh');
		}
	
		$user = $this->ion_auth->user()->row();
		
		$this->load->model('teachers_model');
		$overview = $this->teachers_model->get_overview($user->id);
		
		$data = array('title' => 'Kivaou', 'navbar_content'=>'teacher/teacher_navbar','navbar_style'=>'navbar','navbar_inverse_style'=>'navbar-inverse','navbar_inner_style'=>'navbar-inner','main_content'=>'teacher/teacher_v','user'=>$user,'rooms'=>$overview);
		$this->load->view('templates/home', $data);
	}
	
	public function create_entry()
	{
		//is the user logged in?
		if (!$this->ion_auth->logged_in())
		{
			//redirect them back to the page they came from
			redirect($this->config->item('base_url'), 'refresh');
		}
	
		$user = $this->ion_auth->user()->row();
		$this->load->model('rooms_model');
		$rooms = $this->rooms_model->get_rooms();		
		$this->load->model('classes_model');
		$classes = $this->classes_model->get_classes();
		
		$data = array('title' => 'Kivaou', 'navbar_content'=>'teacher/teacher_navbar','navbar_style'=>'navbar','navbar_inverse_style'=>'navbar-inverse','navbar_inner_style'=>'navbar-inner','main_content'=>'teacher/create_entry','user'=>$user,'rooms'=>$rooms,'classes'=>$classes, 'scripts'=>javascript('create_entry'));
		$this->load->view('templates/home', $data);	
	}
	
	public function roll_call()
	{
		//is the user logged in?
		if (!$this->ion_auth->logged_in())
		{
			//redirect them back to the page they came from
			redirect($this->config->item('base_url'), 'refresh');
		}

		$user = $this->ion_auth->user()->row();
		$this->load->model('rooms_model');
		$rooms = $this->rooms_model->get_rooms();		


		$data = array('title' => 'Kivaou', 'navbar_content'=>'teacher/teacher_navbar','navbar_style'=>'navbar','navbar_inverse_style'=>'navbar-inverse','navbar_inner_style'=>'navbar-inner','main_content'=>'teacher/roll_call','user'=>$user,'rooms'=>$rooms,'scripts'=>javascript('roll_call'));
		$this->load->view('templates/home', $data);	
		
	}
}